<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
	<head>
		<title>Transcript of Records</title>
	
	<script src="../lib/prototype.js" type="text/javascript"></script>
	<script src="../lib/scriptaculous.js" type="text/javascript"></script>
	<script src="../src/spam.js" type="text/javascript"></script>
	<script src="../src/print.js" type="text/javascript"></script>
	
	<script language="JavaScript">
		courses = <?php if (isset($_POST['data'])) echo str_replace("\\\"", '"', $_POST['data']); else echo "{}"; ?>;
	</script>
	
	<style>
		body {
			width: 19cm;
			padding: 2cm;
			margin: 0cm;
			font-size: 10pt;
		}
		body, p, td, input {
			font-family: Georgia, Baskerville, Serif, Times;
		}
		p {
			margin-top: 0px;
			margin-bottom: .2cm;
		}
		#courses {
			border-spacing: 0px;
			font-size: 9pt;
			margin-top: .5cm;
			margin-bottom: .5cm;
			width: 19cm;
		}
		#courses td {
			border-bottom: 1px solid #666;
			padding: .2cm;
		}
		#courses tr td {
			width: 1.5cm;
		}
		#courses tr td:first-child + td{
			width: 11cm;
		}
		
		#courses tr:hover {
			background-color: #eee;
		}
		thead, tr.headrow {
			font-weight: bold;
			background-color: #ddd;
		}
		thead td, tr.headrow td {
			border-top: 1px solid #666;
			vertical-align: bottom;
		}
		table td {
			padding: .2cm;
			vertical-align: top;
		}
		.ectsinfo {
			border-spacing: 0px;	
			width: 14cm;
		}
		.ectsinfo td:first-child, .ectsinfo td:first-child +td  {
			text-align: center;	
		}
		.ectsinfo td {
			padding: .1cm;
			border-bottom: 1px solid #666;
		}
		#nameinput {
			border: none;
			font-size: 12pt;
			font-weight: bold;
			text-align: center;
			border-bottom: 1px solid #666; 
			border-top: 1px solid transparent;
			width: 9cm;
			height: 20px;
			padding: 2px;
		}
		
		#nameinput:hover, #nameinput:active {
			background: url('edit.png') 2px right no-repeat #ddf;
			border: 1px solid #99b;
			-moz-border-radius: 4px;
		    -webkit-border-radius: 4px;
			
		}
		table tr:hover td.del {
			background: url('delete.png') 4px right no-repeat ;
			cursor: pointer;
		}

		table td.edit:hover {
			background: url('edit.png') 4px right no-repeat #ddf;
			cursor: text;
		}
		
		table td.edit:hover + td + td + td.del, table td.edit:active + td + td + td.del {
			background: #eee;
		}
		table td.edit input {
			width: 100%;
			border: none;
			margin: none;
			height: 100%;
			background: transparent;
		}
		table td.edit:hover input {
			width: 90%;
		}
		#courses tr.add td{
			border-bottom: none;
		}
		#courses tr.add:hover {
			background: transparent;
		}
		#courses tr.add:hover td.add{
			background: url('add.png') 4px right no-repeat ;
			cursor: pointer;
		}
		
		.spanrow td {
            height: 1cm;
            vertical-align: bottom

		}
		
	</style>
	</head>
	
	<body>
	
	<div style="float: right; border: 1px solid black; padding: .2cm;">
		School / Department: <em>Fachbereich / Fach</em>:<br />
			<b>Cognitive Science</b>
	</div>
	<div id="debug" style="color: red;"></div>
	<div>
		<p><b>
		Universit&auml;t Osnabr&uuml;ck<br />
		49069 Osnabr&uuml;ck<br />
		Germany</b>
		</p><p>
		International Office<br />
		D-49069 Osnabr&uuml;ck<br />
		Tel.: + 49 (0) 541 969 4126 <br />
		Email: <span style="font-family: Courier;">AAA@uni-osnabrueck.de</span><br />
		<p>
		
		
	</div>
	
	<center>
	<h2>Transcript of Records</h2>
		<p>We hereby confirm that Mr / Ms</p>
		<p><input type="text" id="nameinput" value="Ann Onymus"></p>
		<p>has completed the following study programme</p>
	</center>
	<table id="courses">
		<thead>
			<tr>
				<td>Term</td>
				<td>Title of Course</td>
				<td>Unit Code<sup>(1)</sup></td>
				<td>ECTS points<sup>(2)</sup></td>
				<td>Grade<sup>(3)</sup></td>
			</tr>
		</thead>
		<tbody id="tablebody">
		</tbody>
		
		</table>
		
		<div style="width: 95%; padding: .5cm; border: 1px solid black; margin-bottom: .5cm">
			 List of Courses and Grades in Transcript Verified
			
			<table style="width: 100%">
				<tr>
					<td style="border-bottom: 1px solid #666; width: 4cm;">&nbsp;</td>
					<td>&nbsp;</td>
					<td style="border-bottom: 1px solid #666">&nbsp;</td>
				</tr><tr>
					<td>Date</td>
					<td>&nbsp;</td>
					<td>Institutional Co- ordinator</td>
				</tr><tr>
					<td style="color: #666">(Seal)</td>			
					<td>&nbsp;</td>
					<td>International Office of the University of Osnabr&uuml;ck </td>
				</tr>
			</table>
			<br />
			 The transcribed courses are in agreement with the departmental rules 


			<table style="width: 100%">
				<tr>
					<td style="border-bottom: 1px solid #666; width: 4cm;">&nbsp;</td>
					<td>&nbsp;</td>
					<td style="border-bottom: 1px solid #666">&nbsp;</td>
				</tr><tr>
					<td>Date</td>
					<td>&nbsp;</td>
					<td>Prof. Dr. Achim Stephan<em>Departmental ECTS Co-ordinator</em></td>
				</tr><tr>
					<td style="color: #666">(Seal)</td>			
					<td>&nbsp;</td>
					<td>Studies in Cognitive Science</td>
				</tr>
			</table>
			
		</div>
		<div style="width: 18cm; padding: .5cm; border: 1px solid black;">
			<center>
			 	Degree awarded (if appropriate): <em style="margin-left: 3cm;">Verliehener Abschlu&szlig; (falls zutreffend):</em> 
			 	<p style="width: 9cm; border-bottom: 1px solid #666; height: 1cm">&nbsp;</p>
			</center>
		</div>
		
		<h3>Explanations: </h3>
		<table style="width: 19cm;">
			<tr>
				<td>(1)</td>
				<td>
					Please refer to the relevant ECTS INFO Brochure for further information on the course unit. <br/>
					<em>Bitte entnehmen Sie die Informationen aus der entsprechenden ECTS INFO Brosch&uuml;re. </em>
				</td>
			</tr>
			<tr>
				<td>(2)</td>
				<td>
					For a description of the institutional grading system please refer to the relevant section of the ECTS Info brochure. <br/>
					<em>Eine Beschreibung des Benotungssystems finden Sie in der ECTS INFO Brosch&uuml;re. </em>
				</td>
			</tr>
			<tr>
				<td>(3)</td>
				<td>
					ECTS Grading Scale:<br/>
					<em>ECTS Benotungssystem:</em>
					<br /><br />
					<table class="ectsinfo">
						<thead>
						<tr>
							<td>ECTS Grade</td>
							<td style="width: 4cm">% of <strong>successful</strong> students normally achieving this 	grade </td>
							<td style="width: 6cm">Description / Definition </td>
						</tr>
						</thead>
						<tr>
							<td>A </td>
							<td>10 </td>
							<td> EXCELLENT - Outstanding performance 
						</tr>
						<tr>
							<td>B </td>
							<td> 25 </td>
							<td> VERY GOOD - above the average standard 
						</tr>
						<tr>
							<td>C </td>
							<td> 30 </td>
							<td> GOOD - generally sound work 
						</tr>
						<tr>
							<td>D </td>
							<td> 25 </td>
							<td> SATISFACTORY - fair but with significant shortcomings 
						</tr>
						<tr>
							<td>E </td>
							<td> (--) </td>
							<td> SUFFICIENT - performance meets the minimum criteria 
						</tr>
						<tr>
							<td>F </td>
							<td> (--) </td>
							<td> FAIL - considerable further work is required 
						</tr>
						<tr>
							<td>IP </td>
							<td> (--) </td>
							<td> IN PROGRESS, the course is not yet completed or the grades have not yet been provided by instructor 
						</tr>
					</table>
					
				</td>
			</tr>
        
		
		</table>
		

		<script language="JavaScript">
		function sortfunction(keya, keyb) {
			// suppose we get two course hashes
	        a = courses[keya];
	        b = courses[keyb];

	        if (a.instance.year > b.instance.year) return -1;
	        else if (a.instance.year < b.instance.year) return 1;
	        else if (a.instance.term < b.instance.term) return -1;
	        else if (a.instance.term > b.instance.term) return 1;
	        else if (a.grade < b.grade) return -1;
	        else return 1;
			return 0;
    	}

		function deleteColumn(id) {
			$("tr"+id).fade();
		}


        var coursekeys = $H(courses).keys();
        coursekeys.sort(sortfunction);

		var text = "";

        for (var i = 0; i<coursekeys.size(); i++) {
        
			c = courses[coursekeys[i]]
			
			if (!c.external) {
                var term = c.instance.term == "1" ? "WS " : "SS ";
                text += "\t<tr id='tr"+coursekeys[i]+"'>\n";            
     			text += "\t\t<td>"+term+c.instance.year+"</td>\n";
                text += "\t\t<td class='edit'><input type='text' value=\""+c.name+"\" /></td>\n";
                text += "\t\t<td>"+c.instance.key+"</td>\n";
                text += "\t\t<td>"+c.credits+"</td>\n";
                text += "\t\t<td class='del' onclick='deleteColumn(\""+coursekeys[i]+"\")'>"+grade2str(c.grade)+"</td>\n";
                text += "\t</tr>\n";
    			
    			}	
        }
        
        text += "\t<tr class='spanrow'><td colspan='5'>Courses transferred from other universities:</td></tr>";
        
        text += "\n\t<tr class='headrow'><td>Term and University</td><td>Title of Course</td><td>Unit Code<sup>(1)</sup></td><td>ECTS points<sup>(2)</sup></td><td>Grade<sup>(3)</sup></td></tr>\n\t\n";

       for (var i = 0; i<coursekeys.size(); i++) {
        
			c = courses[coursekeys[i]]
			
			if (c.external) {
                var term = c.instance.term == "1" ? "WS " : "SS ";
                text += "\t<tr id='tr"+coursekeys[i]+"'>\n";            
     			text += "\t\t<td>"+term+c.instance.year+"</td>\n";
                text += "\t\t<td class='edit'><input type='text' value=\""+c.name+"\" /></td>\n";
                text += "\t\t<td>"+c.instance.key+"</td>\n";
                text += "\t\t<td>"+c.credits+"</td>\n";
                text += "\t\t<td class='del' onclick='deleteColumn(\""+coursekeys[i]+"\")'>"+grade2str(c.grade)+"</td>\n";
                text += "\t</tr>\n";
    			
    			}	
        }       
        
		text += "\t<tr class='add'><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td class='add'>&nbsp;</td></tr>"

		$("tablebody").innerHTML = text;
		
		Sortable.create($("tablebody"), {tag: 'td'});
		</script>
		
	</body>
</html>
